package com.ruoyi.project.service;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mapper.CommentMapper;
import com.ruoyi.project.domain.Comment;
import com.ruoyi.project.service.ICommentService;
import com.ruoyi.common.support.Convert;

/**
 * 评论 服务层实现
 * 
 * @author ruoyi
 * @date 2018-11-01
 */
@Service
public class CommentServiceImpl implements ICommentService 
{
	@Autowired
	private CommentMapper commentMapper;

	/**
     * 查询评论信息
     * 
     * @param commentId 评论ID
     * @return 评论信息
     */
    @Override
	public Comment selectCommentById(Long commentId)
	{
	    return commentMapper.selectCommentById(commentId);
	}
	
	/**
     * 查询评论列表
     * 
     * @param comment 评论信息
     * @return 评论集合
     */
	@Override
	public List<Comment> selectCommentList(Comment comment)
	{
	    return commentMapper.selectCommentList(comment);
	}
	
    /**
     * 新增评论
     * 
     * @param comment 评论信息
     * @return 结果
     */
	@Override
	public int insertComment(Comment comment)
	{
	    return commentMapper.insertComment(comment);
	}
	
	/**
     * 修改评论
     * 
     * @param comment 评论信息
     * @return 结果
     */
	@Override
	public int updateComment(Comment comment)
	{
	    return commentMapper.updateComment(comment);
	}

	/**
     * 删除评论对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteCommentByIds(String ids)
	{
		return commentMapper.deleteCommentByIds(Convert.toStrArray(ids));
	}

	/**
	 * 根据学员的id查询这个学员所有的评论信息
	 * @param userId
	 * @return
	 */
	@Override
	public List<Comment> selectCommentuserId(long userId){
		Comment comment=new Comment();
		comment.setUserId(userId);
		return commentMapper.selectCommentList(comment);
	}

	/**
	 * 根据学员姓名查询评论信息
	 * @param userName
	 * @return
	 */
	@Override
	public List<Comment> selectCommentuserName(String userName){
		Comment comment=new Comment();
		comment.setUserName(userName);
		return commentMapper.selectCommentList(comment);
	}

	/**
	 * 根据教师id查询评论
	 * @param teacherId
	 * @return
	 */
	@Override
	public List<Comment> selectCommentteacherId(long teacherId){
		Comment comment =new Comment();
		comment.setTeacherId(teacherId);
		return commentMapper.selectCommentList(comment);
	}

	/**
	 * 根据教师姓名查询评论信息
	 * @param teacherName
	 * @return
	 */
	@Override
	public List<Comment> selectCommentteacherName(String teacherName){
		Comment comment=new Comment();
		comment.setTeacherName(teacherName);
		return commentMapper.selectCommentList(comment);
	}

	/**
	 * 根据日期查询评论信息
	 * @param createTime
	 * @return
	 */
	@Override
	public List<Comment> selectCommentcreateTime(Date createTime){
		Comment comment=new Comment();
		comment.setCreateTime(createTime);
		return commentMapper.selectCommentList(comment);
	}
}
